<?php
class hrd_tunjangan_kesehatan_model extends MY_Model {
	var $nama_tabel = 'hrd_tunjangan_kesehatan';
	
	function GetJSON() {
		$ls_sql	= "	SELECT	a.*, b.nama_status
					FROM	".$this->nama_tabel." a
					LEFT JOIN HRD_STATUS_KAWIN b ON a.id_status_kawin_fk = b.id_status_kawin_pk
					WHERE	(UPPER(id_tunjangan_kesehatan_pk) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(level_tunjangan_kesehatan) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(jumlah) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(b.nama_status) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(NVL(ket_tunjangan_kesehatan,'')) LIKE '%".strtoupper(post('keyword'))."%')
					ORDER BY ".(post('sort')=='' ? 'id_tunjangan_kesehatan_pk' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
					
		return json_encode( $this->paging($ls_sql) );
	}

	function Add($arr_data){
		$this->db->insert($this->nama_tabel, $arr_data);
	}

	function Update($arr_data, $arr_rule){
		$this->db->update($this->nama_tabel, $arr_data, $arr_rule);
	}

	function DeleteSingle($arr_rule) {
		try {
			$this->db->delete($this->nama_tabel, array('id_tunjangan_kesehatan_pk' => $arr_rule['id_tunjangan_kesehatan_pk']));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}

}
?>